package com.qky.note.part10javatrans;

import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CodePointCharStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;

public class Test {
    public static void main(String[] args) {
        CodePointCharStream input = CharStreams.fromString("interface IDemo {\n" +
                "\tvoid f(int x, String y);\n" +
                "\tint[ ] g(/*no args*/);\n" +
                "\tList<Map<String, Integer>>[] h();\n" +
                "}");
        JavaLexer lexer = new JavaLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        JavaParser parser = new JavaParser(tokens);
        ParseTree tree = parser.compilationUnit(); // parse
//
        ParseTreeWalker walker = new ParseTreeWalker();
        ExtractInterfaceListener extractInterfaceListener = new ExtractInterfaceListener(parser);
        walker.walk(extractInterfaceListener, tree);
    }
}
